package com.goldenlight.fvms.manager.config;

import com.goldenlight.fvms.manager.utils.LogUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
public class LoggerConfig {
    @RequestMapping("/changeLog/{level}")
    public String changeLevel(@PathVariable String level, @RequestBody String packages) {
        log.info("start >>> 修改日志级别：{},作用域：{}", level, packages);
        if (StringUtils.isEmpty(packages)) {
            LogUtils.setAllLogLevel(level);
        } else {
            LogUtils.setLogLevel(packages, level);
        }
        log.info("end >>> 修改日志级别");
        return "success";
    }
}
